HAVE_EVAS=$(shell pkg-config --exists evas 2>/dev/null && echo 'yes')
HAVE_ECORE_EVAS=$(shell pkg-config --exists ecore-evas 2>/dev/null && echo 'yes')
HAVE_ECORE=$(shell pkg-config --exists ecore 2>/dev/null && echo 'yes')
HAVE_ENDER=$(shell pkg-config --exists ender 2>/dev/null && echo 'yes')

ifeq ($(HAVE_EVAS),yes)
EVAS_CFLAGS = $(shell pkg-config --cflags evas)
EVAS_LIBS = $(shell pkg-config --libs evas)
endif

ifeq ($(HAVE_ECORE_EVAS),yes)
ECORE_EVAS_CFLAGS = $(shell pkg-config --cflags ecore-evas)
ECORE_EVAS_LIBS = $(shell pkg-config --libs ecore-evas)
endif

ifeq ($(HAVE_ENDER),yes)
ENDER_CFLAGS = $(shell pkg-config --cflags ender)
ENDER_LIBS = $(shell pkg-config --libs ender)
endif

ifeq ($(HAVE_ECORE),yes)
ECORE_CFLAGS = $(shell pkg-config --cflags ecore)
ECORE_LIBS = $(shell pkg-config --libs ecore)
endif

libefl_ender_so_GENERATED = \
efl_ender_evas_generated.c \
efl_ender_evas_object_generated.c

libefl_ender_so_SRCS = \
efl_ender_evas.c \
efl_ender_evas_object.c

libefl_ender_so_CFLAGS = \
$(ECORE_EVAS_CFLAGS) \
$(EVAS_CFLAGS) \
$(ENDER_CFLAGS) \
-fPIC

libefl_ender_so_LIBS = \
$(ECORE_EVAS_LIBS) \
$(EVAS_LIBS) \
$(ENDER_LIBS) \
-shared

libefl_ender_so: $(libefl_ender_so_GENERATED) $(libefl_ender_so_SRCS)
	$(RM) $@
	@echo $(ENDER_LIBS)
	$(CC) $(libefl_ender_so_SRCS) -o libefl_ender.so $(libefl_ender_so_LIBS) $(libefl_ender_so_CFLAGS)

test01_SRCS = \
test01.c

test01_CFLAGS = \
$(ECORE_EVAS_CFLAGS) \
$(EVAS_CFLAGS) \
$(ENDER_CFLAGS) \
$(ECORE_CFLAGS)

test01_LIBS = \
$(ECORE_EVAS_LIBS) \
$(EVAS_LIBS) \
$(ENDER_LIBS) \
$(ECORE_LIBS) \
-L. -lefl_ender

test01: $(test01_SRCS)
	$(RM) $@
	$(CC) $(test01_SRCS) -o $@ $(test01_LIBS) $(test01_CFLAGS)

BINS = \
libefl_ender_so \
test01

all: $(BINS)

efl_ender_evas_object_generated.c: evas.ender
	ender_generator evas.ender object $@

efl_ender_evas_generated.c: evas.ender
	ender_generator evas.ender evas $@

clean::
	rm -rf $(BINS) $(libefl_ender_so_GENERATED) *.o *~


